package com.zjj.exception.balance;

// 定义 ExceptionTest 类
class ExceptionTest {
    private String id;
    private double balance;

    // 构造函数，初始化账户信息
    public ExceptionTest(String id, double balance) {
        this.id = id;
        this.balance = balance;
    }

    // 取款方法
    public void withdraw(double amount) throws InsufficientBalanceException {
        if (amount <= 0) {
            throw new IllegalArgumentException("取款金额必须为正数");
        }
        if (amount > balance) {
            throw new InsufficientBalanceException("余额不足，无法完成取款");
        }
        balance -= amount;
        System.out.println("取款成功，取出金额：" + amount);
    }

    // 获取当前余额
    public double getBalance() {
        return balance;
    }
}

